namespace Nightlife.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.SpotModels",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false),
                        Created = c.DateTime(nullable: false),
                        Deleted = c.Boolean(nullable: false),
                        IsPublic = c.Boolean(nullable: false),
                        User_ID = c.Int(),
                        User_ID1 = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Users", t => t.User_ID)
                .ForeignKey("dbo.Users", t => t.User_ID1)
                .Index(t => t.User_ID)
                .Index(t => t.User_ID1);
            
            CreateTable(
                "dbo.Checkins",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Created = c.DateTime(nullable: false),
                        User_ID = c.Int(),
                        Spot_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Users", t => t.User_ID)
                .ForeignKey("dbo.SpotModels", t => t.Spot_ID)
                .Index(t => t.User_ID)
                .Index(t => t.Spot_ID);
            
            CreateTable(
                "dbo.Users",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Username = c.String(nullable: false),
                        User_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Users", t => t.User_ID)
                .Index(t => t.User_ID);
            
            CreateTable(
                "dbo.CommentModels",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Comment = c.String(),
                        Discriminator = c.String(nullable: false, maxLength: 128),
                        Owner_ID = c.Int(),
                        CommentModel_ID = c.Int(),
                        Owner_ID1 = c.Int(),
                        User_ID = c.Int(),
                        User_ID1 = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.SpotModels", t => t.Owner_ID)
                .ForeignKey("dbo.CommentModels", t => t.CommentModel_ID)
                .ForeignKey("dbo.SpecialModels", t => t.Owner_ID1)
                .ForeignKey("dbo.Users", t => t.User_ID)
                .ForeignKey("dbo.Users", t => t.User_ID1)
                .Index(t => t.Owner_ID)
                .Index(t => t.CommentModel_ID)
                .Index(t => t.Owner_ID1)
                .Index(t => t.User_ID)
                .Index(t => t.User_ID1);
            
            CreateTable(
                "dbo.SpecialModels",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Description = c.String(),
                        Created = c.DateTime(nullable: false),
                        Start = c.DateTime(nullable: false),
                        End = c.DateTime(nullable: false),
                        Creator_ID = c.Int(),
                        Spot_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Users", t => t.Creator_ID)
                .ForeignKey("dbo.SpotModels", t => t.Spot_ID)
                .Index(t => t.Creator_ID)
                .Index(t => t.Spot_ID);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.SpecialModels", new[] { "Spot_ID" });
            DropIndex("dbo.SpecialModels", new[] { "Creator_ID" });
            DropIndex("dbo.CommentModels", new[] { "User_ID1" });
            DropIndex("dbo.CommentModels", new[] { "User_ID" });
            DropIndex("dbo.CommentModels", new[] { "Owner_ID1" });
            DropIndex("dbo.CommentModels", new[] { "CommentModel_ID" });
            DropIndex("dbo.CommentModels", new[] { "Owner_ID" });
            DropIndex("dbo.Users", new[] { "User_ID" });
            DropIndex("dbo.Checkins", new[] { "Spot_ID" });
            DropIndex("dbo.Checkins", new[] { "User_ID" });
            DropIndex("dbo.SpotModels", new[] { "User_ID1" });
            DropIndex("dbo.SpotModels", new[] { "User_ID" });
            DropForeignKey("dbo.SpecialModels", "Spot_ID", "dbo.SpotModels");
            DropForeignKey("dbo.SpecialModels", "Creator_ID", "dbo.Users");
            DropForeignKey("dbo.CommentModels", "User_ID1", "dbo.Users");
            DropForeignKey("dbo.CommentModels", "User_ID", "dbo.Users");
            DropForeignKey("dbo.CommentModels", "Owner_ID1", "dbo.SpecialModels");
            DropForeignKey("dbo.CommentModels", "CommentModel_ID", "dbo.CommentModels");
            DropForeignKey("dbo.CommentModels", "Owner_ID", "dbo.SpotModels");
            DropForeignKey("dbo.Users", "User_ID", "dbo.Users");
            DropForeignKey("dbo.Checkins", "Spot_ID", "dbo.SpotModels");
            DropForeignKey("dbo.Checkins", "User_ID", "dbo.Users");
            DropForeignKey("dbo.SpotModels", "User_ID1", "dbo.Users");
            DropForeignKey("dbo.SpotModels", "User_ID", "dbo.Users");
            DropTable("dbo.SpecialModels");
            DropTable("dbo.CommentModels");
            DropTable("dbo.Users");
            DropTable("dbo.Checkins");
            DropTable("dbo.SpotModels");
        }
    }
}
